package com.joysuch.wwyt.licence.util;

import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;

/**
 * @author qingzhou
 * 8/22/18
 */
public class LicUtil {
    private static final String PRI_KEY = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAy39ADMQZ20Qyg84nXTAAyOtpP-FMMfcq96k9kgiOPO1C_fsqzGc26G_2EGYnefo4OyA6L_WmIVc0foYo5d20rwIDAQABAkAN-QrY1Y5A9AnT6w_g4i7rnN55OGsW8zXME57arCO4IyMeXKLSWUwrYLA378zyo8gNyv7kZJ-fc5rC6JtfX67hAiEA63iYJuaQUhqN98_gxvEMdLZWHxIj-VGmwp1sdvcl_LsCIQDdPQm_AZgsN9_32EyqWgLF7qgpQnuoe8Pjg5xo42TCnQIhAOpcYLN3D3VoUJyxHftjtw4C3LyYBY4EIoHYxTeyzPA5AiEA2P3gDEatEVmwQ3AUKdVk-OvOZcF-dc8GX6UbiMjXcAUCIDIuqNc8vLjZu267dfi0wjro9Jvt2iDsPTglgUfqjkJE";

    public static void main(String[] args) throws InvalidKeySpecException, NoSuchAlgorithmException {
        System.out.println(decrypt("1918FC80B1113441A9ACB1001C2FE510009KCLBWxO5ExRg3Sna-ty8x-wjxnJJyQmua02S-GwS7dx7cEbY5mAzXwUC1nilAsHQ_A1Ewy8FqpHCP3zwfoSdqm-vTRcBktiwElBv1zcgaIduQMKMWJXNABvDGB2DRVTbY2Ds3OlsZ-Up-jGZLHD1BpvOFpjdn4DRXJ3hdUCLy1rhUiuFq1EjhazZQa1O5RS73Wyjn_CxlzFdwW28WJCVB3pvse3hpGlht660PRTVa8t7hzNIOCI7uq1hkCLujLJjK1lTlNov_8sxX7CeF9PwpQYiQ4YsOIxcNf2ZENp7k_Y5qDh4qa_ZDAFNuiXOTXY2n4Cxb5vDvGE5_ZBOhlnePHeQAsO3vK0aKLkfp44m_FPCRPe1mn418Mwsanhda8tCH06DrQ5BWUyZuX9DoLzH3GuFqLmpc6G7-7CEJ1jSM2YebY"));
// {"buildId":"204566","buildName":"测试","endDate":1652803200000,"permissionJson":"[]","projectName":"东数网络+赛迪生物科技五位一体项目合同","remark":"","startDate":1651680000000}
        //        System.out.println(encrypt("{\"applicationType\":\"chemical\",\"buildId\":\"200036\",\"buildName\":\"低频触发演示\",\"endDate\":1661235013000,\"permissionJson\":\"[{\\\"name\\\":\\\"巡更管理123\\\",\\\"valid\\\":true},{\\\"name\\\":\\\"智能巡检abc111\\\",\\\"valid\\\":true}]\",\"projectName\":\"test3\",\"remark\":\"\",\"startDate\":1641235046000}"));
    }


    public static String decrypt(String encrypted) throws InvalidKeySpecException, NoSuchAlgorithmException {
        return RsaUtils.privateDecrypt(encrypted, RsaUtils.getPrivateKey(PRI_KEY));
    }

}
